﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using GroupManager.Resource.CSDL;
namespace GroupManager.Class
{
    public class LopDoiNhom
    {
        public static bool KiemTraDoiNhom(int MaDoiNhom)
        {
            dbGroupManagerDataContext db = new dbGroupManagerDataContext();
            var doinhom = db.DoiNhoms.Where(p => p.MaDoiNhom == MaDoiNhom);
            if (doinhom.Count() == 0)
                return true;
            return false;
        }
        public static string LayThongTinNhom(int MaDoiNhom)
        {
            dbGroupManagerDataContext db = new dbGroupManagerDataContext();
            return db.Others.First(p => p.MaDoiNhom == MaDoiNhom).ThongTinNhom;
        }
        public static string LayBanner(int MaDoiNhom)
        {
            dbGroupManagerDataContext db = new dbGroupManagerDataContext();
            return db.Others.First(p => p.MaDoiNhom == MaDoiNhom).Banner;
        }
        public static string LayLogo(int MaDoiNhom)
        {
            dbGroupManagerDataContext db = new dbGroupManagerDataContext();
            return db.Others.First(p => p.MaDoiNhom == MaDoiNhom).Logo;
        }

        public static void SuaBanner(int _madoinhom, string _banner)
        {
            dbGroupManagerDataContext db = new dbGroupManagerDataContext();
            Other ot = db.Others.First(p => p.MaDoiNhom == _madoinhom);
            ot.Banner = _banner;
            db.SubmitChanges();
        }
        // Sửa logo 
        public static void SuaLogo(int _madoinhom, string _logo)
        {
            dbGroupManagerDataContext db = new dbGroupManagerDataContext();
            Other ot = db.Others.First(p => p.MaDoiNhom == _madoinhom);
            ot.Logo = _logo;
            db.SubmitChanges();
        }
        // Sửa thông tin nhóm 
        public static void SuaThongTinNhom(int _madoinhom, string _thongtinnhom)
        {
            dbGroupManagerDataContext db = new dbGroupManagerDataContext();
            Other ot = db.Others.First(p => p.MaDoiNhom == _madoinhom);
            ot.ThongTinNhom = _thongtinnhom;
            db.SubmitChanges();
        }
    }
}